﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using IosDatamodel;
using System.Web.Mvc;
using System.Data.Entity;
using System.Data;
using IOSpro.Lib;
using IOSpro.Models;
namespace IOSpro.Lib
{

    public class VideosheetBL :IVideosheetBL
    {
        private IosDBEntities db;
        private ModelStateDictionary _errorLog;

        public VideosheetBL(ModelStateDictionary modelState)
        {
            _errorLog = modelState;
            db = new IosDBEntities();
        
        }
        public VideosheetBL()
        {
           
            db = new IosDBEntities();

        }



        public bool SaveVideosheetname(VideosheetAdd Model)
        {
            VideoSheet videosheetinfo = new VideoSheet
            { 
                VideoUrlName=Model.videourlname.Trim(),              
                 Text=Model.jianjie,
                Name = Model.name
                  
  
            };
            db.VideoSheet.Add(videosheetinfo);       
        db.SaveChanges();
        return true;
        }


        public bool SaveVideosheetimage(int videosheetid, string videosheetimage) 
        {
            //Videos videonew = new Videos
            //{
            //    Id = videoid,
            //    VideoImage = videoimageurl

            //};
       //     db.Videos.Attach(videonew);
            db.VideoSheet.Where(a => a.Id == videosheetid).FirstOrDefault().Image = videosheetimage;
            db.SaveChanges();
            return true;
             
        }


        public IQueryable<VideoSheet> GetAllVideosheetInfo() 
        {
            return db.VideoSheet.OrderBy(a => a.Id);       
        }
    }
}